#include "gtest/gtest.h"
#include "MatrixGraph.h"
#include <iostream>

using namespace std;
using namespace DTLib;

namespace {

    TEST(MatrixGraph, dijkstra) {

        MatrixGraph<4, int, int> g;
        g.setEdge(0, 1, 1);
        g.setEdge(0, 2, 3);
        g.setEdge(1, 2, 1);
        g.setEdge(1, 3, 5);
        g.setEdge(2, 3, 1);

        SharedPointer< Array<int> > p = g.dijkstra(0, 3, 65535);
        ASSERT_EQ((*p)[0], 0);
        ASSERT_EQ((*p)[1], 1);
        ASSERT_EQ((*p)[2], 2);
        ASSERT_EQ((*p)[3], 3);

    }

    TEST(MatrixGraph, floyd) {

        MatrixGraph<4, int, int> g;
        g.setEdge(0, 1, 2);
        g.setEdge(0, 2, 1);
        g.setEdge(1, 2, 1);
        g.setEdge(1, 3, 5);
        g.setEdge(2, 3, 1);

        SharedPointer< Array<int> > pf = g.floyd(0, 3, 65535);
        ASSERT_EQ((*pf)[0], 0);
        ASSERT_EQ((*pf)[1], 2);
        ASSERT_EQ((*pf)[2], 3);
    }

}
